package com.ruoyi.web.app.chat;

import com.ruoyi.common.base.chat.dto.ChatMessageAddDTO;
import com.ruoyi.common.base.chat.dto.ChatMessageAppListCondition;
import com.ruoyi.common.base.chat.vo.ChatMessageAddRes;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.web.service.IChatMessageService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 会话记录Controller
 *
 * @author gdk
 * @date 2023-05-15
 */
@RestController
@AllArgsConstructor
@RequestMapping("/app/chat/message")
public class ChatMessageAppController extends BaseController {
    private final IChatMessageService chatMessageService;

    /**
     * 记录新消息
     *
     * @param dto dto
     * @return {@link AjaxResult}
     * @author gdk
     * @since 2023/5/16 16:33
     */
    @PostMapping
    public AjaxResult add(@RequestBody ChatMessageAddDTO dto) {
        ChatMessageAddRes res = chatMessageService.add(dto);
        return success(res);
    }

    /**
     * 消息记录
     *
     * @param condition condition
     * @return {@link TableDataInfo}
     * @author gdk
     * @since 2023/5/16 16:33
     */
    @GetMapping("/list")
    public TableDataInfo list(ChatMessageAppListCondition condition) {
        startPage();
        return chatMessageService.appList(condition);
    }
}
